using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ManageUsers : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void deleteButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (((TextBox)LoginViewAdmin.FindControl("deleteName")).Text != "yurttas")
            {
                Membership.DeleteUser(((TextBox)LoginViewAdmin.FindControl("deleteName")).Text, true);
                ((GridView)this.LoginViewAdmin.FindControl("UsersList")).DataBind();
            }
            else
            {
                // Can not delete yurttas
            }
        }
        catch (Exception err)
        {
            // ignore it
        }
    }

    protected void adminButton_Click(object sender, EventArgs e)
    {
        try
        {
            Roles.RemoveUserFromRole(((TextBox)LoginViewAdmin.FindControl("adminName")).Text, "user");
            Roles.AddUserToRole(((TextBox)LoginViewAdmin.FindControl("adminName")).Text, "admin");
            ((GridView)this.LoginViewAdmin.FindControl("UsersList")).DataBind();
        }
        catch (Exception err)
        {
            // ignore it
        }
    }
}
